package me.mcxiafeng;

import java.util.ArrayList;

import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;

import me.mcxiafeng.Event.ClickGiftEvent;
import me.mcxiafeng.GUI.GuiClickGift;

public class Main extends JavaPlugin implements Listener{
	
	public static Main instease;
	
	@Override
	public void onEnable() {
		this.instease = this;
		GuiClickGift.putgiftmap();
		Bukkit.getPluginManager().registerEvents(new ClickGiftEvent(), this);
		this.getConfig().addDefault("prize", new ArrayList<>());
		this.saveConfig();
		super.onEnable();
	}
	
	@Override
	public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
		if(!(sender instanceof Player)) {
			Bukkit.getConsoleSender().sendMessage("§c此命令仅允许玩家执行 ");
		}
		Player player = (Player) sender;
		if(command.getName().equalsIgnoreCase("gift")) {
			if(args.length == 1) {
				if(args[0].equalsIgnoreCase("create")) {
					GuiClickGift.OnGui(player);
				}
			}
		}
		
		return false;
	}

}
